import { getDeptList,getDeptTree } from '@/api/system/account';
import { VxeFormItemProps, VxeGridPropTypes } from '@gui-pkg/antdcomponents';
import { Tag } from 'ant-design-vue';
import { getOptionselect } from '@/api/system/role';

export const columns: VxeGridPropTypes.Columns = [
  {
    title: '序号',
    type: 'seq',
    fixed: 'left',
    width: '70',
    align: 'center',
  },
  {
    title: '人员名称',
    field: 'nickName',
    align: 'center',
    fixed: 'left',
  },
  {
    title: '联系方式',
    field: 'phonenumber',
    align: 'center',
  },
  {
    title: '职位',
    field: 'position',
    align: 'center',
  },
  {
    title: '工作职责',
    field: 'duty',
    align: 'center',
  },

  {
    title: '登录名',
    field: 'userName',
    align: 'center',
  },
  {
    width: 160,
    title: '操作',
    align: 'center',
    slots: { default: 'action' },
    fixed: 'right',
  },
];

export const searchFormSchema: VxeFormItemProps[] = [
  {
    field: 'nickName',
    title: '人员名称',
    itemRender: {
      name: 'AInput',
    },
    span: 6,
  },
  {
    span: 18,
    align: 'right',
    className: '!pr-0',
    itemRender: {
      name: 'AButtonGroup',
      children: [
        {
          props: { type: 'primary', content: '查询', htmlType: 'submit' },
          attrs: { class: 'mr-2' },
        },
        { props: { type: 'default', htmlType: 'reset', content: '重置' } },
      ],
    },
  },
];

export const accountFormSchema = [
  {
    field: 'userName',
    label: '登录名',
    component: 'Input',
    helpMessage: ['不能输入带有admin的用户名'],
    required: true,
  },
  {
    field: 'nickName',
    label: '用户姓名',
    component: 'Input',
    required: true,
  },
  {
    label: '角色',
    field: 'roleIds',
    component: 'ApiSelect',
    componentProps: () => {
      return {
        api: () => new Promise((resolve) => {
          getOptionselect().then((res:any) => {
            console.log('-------',res);
            resolve(res);
          });
        }),
        mode: "multiple",
        fieldNames: {
          label: 'roleName',
          key: 'roleId',
          value: 'roleId',
        },
      };
    },
    required: true,
  },
  {
    field: 'deptId',
    label: '所属部门',
    component: 'ApiTreeSelect',
    componentProps: {
      api: getDeptTree,
      fieldNames: {
        label: 'label',
        key: 'id',
        value: 'id',
      },
      getPopupContainer: () => document.body,
    },
    required: true,
  },
  {
    field: 'position',
    label: '职位',
    component: 'Input',
    required: true,
  },
  {
    field: 'duty',
    label: '工作职责',
    component: 'Input',
    required: true,
  },
  {
    field: 'phonenumber',
    label: '手机号',
    component: 'Input',
  },
  {
    label: '邮箱',
    field: 'email',
    component: 'Input',
  },
  {
    field: 'status',
    label: '状态',
    component: 'RadioButtonGroup',
    defaultValue: "0",
    componentProps: {
      options: [
        { label: '正常', value: "0" },
        { label: '停用', value: "1" },
      ],
    },
  },
];
